package com.microcore.dao.mapper;

import com.microcore.entity.AssertCondition;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface AssertConditionMapper {
    @Delete({
        "delete from tb_ssgp_assert_condition",
        "where fk_id = #{fkId,jdbcType=VARCHAR}"
    })
    int deleteByFK(String fkId);

    @Insert({
        "insert into tb_ssgp_assert_condition (assert_id, fk_id, ",
        "conditions)",
        "values (#{assertId,jdbcType=VARCHAR}, #{fkId,jdbcType=VARCHAR}, ",
        "#{conditions,jdbcType=VARCHAR})"
    })
    int insert(AssertCondition record);

    @InsertProvider(type=AssertConditionSqlProvider.class, method="insertSelective")
    int insertSelective(AssertCondition record);

    @Select({
        "select",
        "assert_id, fk_id, conditions",
        "from tb_ssgp_assert_condition",
        "where assert_id = #{assertId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="assert_id", property="assertId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="fk_id", property="fkId", jdbcType=JdbcType.VARCHAR),
        @Result(column="conditions", property="conditions", jdbcType=JdbcType.VARCHAR)
    })
    AssertCondition selectByPrimaryKey(String assertId);

    @UpdateProvider(type=AssertConditionSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(AssertCondition record);

    @Update({
        "update tb_ssgp_assert_condition",
        "set fk_id = #{fkId,jdbcType=VARCHAR},",
          "conditions = #{conditions,jdbcType=VARCHAR}",
        "where assert_id = #{assertId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(AssertCondition record);

    @Select({
            "select",
            "assert_id, fk_id, conditions",
            "from tb_ssgp_assert_condition",
            "where fk_id = #{fkId,jdbcType=VARCHAR}"
    })
    @Results({
            @Result(column="assert_id", property="assertId", jdbcType=JdbcType.VARCHAR, id=true),
            @Result(column="fk_id", property="fkId", jdbcType=JdbcType.VARCHAR),
            @Result(column="conditions", property="conditions", jdbcType=JdbcType.VARCHAR)
    })
    List<AssertCondition> selectByFK(String fkId);

}
